﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace P3SS.Engine
{
	/// <summary>
	/// Holds a message from an engine
	/// </summary>
	public class EngineMessageEventArgs : EventArgs
	{
		#region Fields
		private string message;
		private MessageType typeOfMessage;
		#endregion
		#region Constructors
		/// <summary>
		/// Default Constructor
		/// </summary>
		public EngineMessageEventArgs()
		{
			message = "";
			typeOfMessage = MessageType.Information;
		}
		#endregion
		#region Properties
		/// <summary>
		/// Message passed from the Engine
		/// </summary>
		public string Message
		{
			get
			{ return message; }
			set
			{ message = value; }
		}

		/// <summary>
		/// Type of message that is being passed
		/// </summary>
		public MessageType TypeOfMessage
		{
			get
			{ return typeOfMessage; }
			set
			{ typeOfMessage = value; }
		}
		#endregion
		#region Methods
		/// <summary>
		/// Converts an error code (EventId or InstanceId) to the MessageType related to it
		/// </summary>
		/// <param name="inErrorCode">EventId or InstanceId for the Event</param>
		/// <returns>The MessageType of the error</returns>
		public static MessageType typeFromErrorCode(int inErrorCode)
		{
			return ((MessageType)(inErrorCode / 100));
		}
		#endregion
	}

	/// <summary>
	/// Types of messages that can be passed from the engine
	/// </summary>
	public enum MessageType
	{
		/// <summary>
		/// Informational message (Of no concern)
		/// </summary>
		Information = 1,
		/// <summary>
		/// Warning message (May be of concern)
		/// </summary>
		Warning = 2,
		/// <summary>
		/// Error message (Of much concern)
		/// </summary>
		Error = 3,
		/// <summary>
		/// Debug message (Of concern to developers)
		/// </summary>
		Debug = 4,
	}

	/// <summary>
	/// Possible categories for the event log
	/// </summary>
	public enum EventLogCategory : short
	{
		/// <summary>
		/// An event caused by the service itself
		/// </summary>
		Service = 0,
		/// <summary>
		/// An event caused by the POP3 engine
		/// </summary>
		Pop3 = 1,
		/// <summary>
		/// An event caused by the SMTP engine
		/// </summary>
		Smtp = 2,
	}
}
